# 1. 导入threading模块
import threading
import time


# 跳舞任务函数
def dance():
    for i in range(4):
        print("跳舞中。。。")
        time.sleep(0.2)


# 唱歌任务的函数
def sing():
    for i in range(3):
        print("唱歌中...")
        time.sleep(0.2)


if __name__ == '__main__':

    # sing()
    # dance()

    # 2. 创建子线程对象
    # group: 表示线程组，目前只能使用None
    # target: 表示执行的任务名(函数名或者方法名)
    sub_thread1 = threading.Thread(target=dance)
    print(sub_thread1, sub_thread1.name)
    sub_thread2 = threading.Thread(target=sing, name="sub_thread2")
    print(sub_thread2, sub_thread2.name)

    # 3. 启动线程执行对应的任务
    sub_thread1.start()
    sub_thread2.start()
